package com.example.demo.use_demo.a_shiro.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 账户
 * @author zhangqiang
 * @version 1.0
 * @date 2025/02/08
 */
@Data
public class Account {

    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 角色
     */
    private Role role;

    public Account(String username, String password, Role role) {
        this.username = username;
        this.password = password;
        this.role = role;
    }

    public static List<Account> allAccount = new ArrayList<Account>(){{
        add(new Account("zs","123123",new Role(null,null)));
        add(new Account("ls","123123",new Role("","manage")));
        add(new Account("ww","123123",new Role("administrator","manage")));
    }};

    public static Account findByUsername(String username){
        return allAccount.stream().filter(i -> i.getUsername().equals(username)).findAny().orElse(null);
    }

}
